﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace JSKE
{
    public class MyDateTimePicker : DateTimePicker
    {
        private DateTime _oldValue;

        //protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        //{
        //    if (keyData == Keys.Up)
        //    {
        //        this.Value = this.Value.AddDays(1);
        //        return true;
        //    }
        //    if (keyData == Keys.Down)
        //    {
        //        this.Value = this.Value.AddDays(-1);
        //        return true;
        //    }
        //    return base.ProcessCmdKey(ref msg, keyData);
        //}
        protected override void WndProc(ref Message m)
        {
            _oldValue = this.Value;
            base.WndProc(ref m);
        }

        public void RollBack()
        {
            this.Value = _oldValue;
        }

        //[StructLayout(LayoutKind.Sequential)]
        //struct NMHDR
        //{
        //    public IntPtr hwndFrom;
        //    public IntPtr idFrom;
        //    public int code;
        //}
        //[StructLayout(LayoutKind.Sequential)]
        //struct NMUPDOWN
        //{
        //    public NMHDR hdr;
        //    public int pos;
        //    public int delta;
        //}
    }
}
